package com.jin.六大设计原则.依赖倒置原则.顺从;

import com.jin.六大设计原则.依赖倒置原则.违背.BetUser;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DrawRandom implements IDraw {
    @Override
    public List<BetUser> prize(List<BetUser> list, int count) {
        //集合数量小，直接返回
        if (list.size()<=count) return list;
        //乱序集合(打乱集合)
        Collections.shuffle(list);
        //取出指定数量的中奖用户
        List<BetUser> prizeList = new ArrayList<>(count);
        for (int i = 0; i < count; i++) {
            prizeList.add(list.get(i));
        }
        return prizeList;
    }
}
